<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<%@ page import="java.util.Collection"%>
<%@ page import="java.util.List"%>

<script language="JavaScript" src="<%= request.getContextPath() + "/js/popUP.js" %>"></script>
<script language="JavaScript" src="<%= request.getContextPath() + "/js/calendar6.js" %>"></script>
<link href="<%= request.getContextPath() + "/css/bloques.css" %>" rel="stylesheet" type="text/css">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reporte Grupo Familiar</title>
  <script>
    
    function habilita(){
      if(document.frmReportGrupoFamiliar.filter.value == "7")
      {
        document.frmReportGrupoFamiliar.CodeValue2.disabled = false; 
      }else
      {
        document.frmReportGrupoFamiliar.CodeValue2.disabled = true; 
        document.frmReportGrupoFamiliar.CodeValue2.value = "";
      }
    
    }  
  
   function verificar(){
     
      document.frmReportGrupoFamiliar.action = '<%=request.getContextPath()+"/Reportes/GrupoFamiliar/TotalSelectFilterRGF.do"%>'
      document.frmReportGrupoFamiliar.accion.value ='Find';
      document.frmReportGrupoFamiliar.target = "_self";
      document.frmReportGrupoFamiliar.submit();
    }
    
    
    function verificar1(){
      if(document.frmReportGrupoFamiliar.filter.value == "7")
      {
  
        if(document.frmReportGrupoFamiliar.CodeValue1.value == "" || document.frmReportGrupoFamiliar.CodeValue2.value == "")
        {
          alert("Por favor ingrese tanto el valor1 como el valor2");
        }else
        {
          document.frmReportGrupoFamiliar.action = '<%=request.getContextPath()+"/Reportes/GrupoFamiliar/TotalSelectFilterRGF.do"%>'
          document.frmReportGrupoFamiliar.accion.value ='Find';
          document.frmReportGrupoFamiliar.accion2.value ='Add';
          document.frmReportGrupoFamiliar.target = "_self";
          document.frmReportGrupoFamiliar.submit();
        }
      }else
      {
        if(document.frmReportGrupoFamiliar.CodeValue1.value == "")
        {
          alert("Por favor ingrese un valor");
        }else
        {
          document.frmReportGrupoFamiliar.action = '<%=request.getContextPath()+"/Reportes/GrupoFamiliar/TotalSelectFilterRGF.do"%>'
          document.frmReportGrupoFamiliar.accion.value ='Find';
          document.frmReportGrupoFamiliar.accion2.value ='Add';
          document.frmReportGrupoFamiliar.target = "_self";
          document.frmReportGrupoFamiliar.submit();
        }
        
      }
    }
    
    function Generar(){
      document.frmReportGrupoFamiliar.target = "blank";
      document.frmReportGrupoFamiliar.submit();
    }
    
    function regresar(){
     
      document.frmReportGrupoFamiliar.action = '<%=request.getContextPath()+"/Reportes/GrupoFamiliar/TotalSelectCriteriaRGF.do"%>'
      document.frmReportGrupoFamiliar.target = "_self";
      document.frmReportGrupoFamiliar.submit();
    }
    
  </script>
  <script src="<%=request.getContextPath()%>/js/displaytag.js" type="text/javascript"></script>
</head>
<body>
<form name="frmReportGrupoFamiliar" action="<%=request.getContextPath()+"/Reportes/GrupoFamiliar/TotalReportGenerationRGF.do"%>" method="get">
  <p align="center" class="titulosenblanco">Reporte Total Grupo Familiar</p>
  <table cellspacing="3" cellpadding="2" border="0" width="10%" align="center">
    <tr>
      <td align="center" class="celdatabla">Parametro</td>
      <td align="center" class="celdatabla">Filtro</td>
      <td align="center" class="celdatabla">Valor1</td>
      <td align="center" class="celdatabla">Valor2</td>
    </tr>
    <tr>
      <td>
      <%Object codigoatri = (Object)request.getAttribute("CodeField"); 
        if(codigoatri==null) codigoatri = "nulo";
      %>  
        <logic:present name="ListShowFilters">
              <logic:iterate id="Filters" name="ListShowFilters" length="1" type="com.cs.beneficios.business.model.RepAtributoVO">
                <div align="center">
                <html:select onchange="verificar()" name="Filters" property="CodeField" title="atributos" styleClass="form" value="<%=(String)codigoatri%>">
                  <option value="nulo">Seleccione un atributo</option>
                  <html:options name="Filters" labelName="nombre" labelProperty="etiqueta" property="nombre" collection="ListShowFilters"/>
                </html:select>
                </div>
              </logic:iterate>
        </logic:present>
      </td>
      <%Object obTipodato = (Object)request.getAttribute("TypeData");
        String strTipoDato="";
        if(obTipodato!=null)
        {
          strTipoDato = (String)request.getAttribute("TypeData");
        }else
        {
          strTipoDato = "A";
        }
        
        if(strTipoDato.equals("A"))
        {
      %>
      <td align="center">
        <select name="filter" class="form">
          <option value="3">IGUAL</option>
          <option value="4">DIFERENTE</option>
        </select>
      </td>
      <%}else{%>      
      <td align="center">
        <select name="filter" onchange="habilita()" class="form">
          <option value="1">MAYOR O IGUAL</option>
          <option value="2">MENOR O IGUAL</option>
          <option value="3">IGUAL</option>
          <option value="4">DIFERENTE</option>
          <option value="5">MENOR</option>
          <option value="6">MAYOR</option>
          <option value="7">ENTRE</option>
        </select>
      </td>
      <%}%>
      <%obTipodato = (Object)request.getAttribute("TypeData");
        strTipoDato="";
        if(obTipodato!=null)
        {
          strTipoDato = (String)request.getAttribute("TypeData");
        }else
        {
          strTipoDato = "A";
        }
        
        if(strTipoDato.equals("A"))
        {
      %>
        <td align="center">
          <input class="form" type="text" name="CodeValue1"/>
        </td>
        <td align="center">
          <input class="form" disabled="disabled" type="text" name="CodeValue2"/>
        </td>
      <%}else{%>      
        <td align="center">
          <input class="form" type="text" name="CodeValue1"/>
        </td>
        <td align="center">
          <input class="form" disabled="disabled" type="text" name="CodeValue2"/>
        </td>
      <%}%>
    </tr>
    <tr>
      <td align="center" colspan="4">
        <P>&nbsp;</P>
        <P>
          <input type="HIDDEN" name="accion">
          <input type="HIDDEN" name="accion2">
          <input type="button" value="Agregar Filtro" onclick="verificar1()"/>
          <input type="button" value="Generar" onclick="Generar()"/>
        </P>
      </td>
    </tr>
  </table>
  
  <logic:present name="ListFiltrado">
    <table  cellspacing="3" cellpadding="2" border="0" width="50%" align="center">
      <tr>
        <td>
          <display:table name="sessionScope.ListFiltrado" id="lfiltro" cellpadding="3" cellspacing="1" style="width:100%" class="bordestable">
                <display:column headerClass="headerTable" title="Atributo" class="Numero" sortable="true">
                    <div align="center">
                    <bean:write name="lfiltro" property="campo" /> 
                    </div>
                </display:column>
                <display:column headerClass="headerTable" title="Filtro" class="Numero" sortable="true">
                    <div align="center">
                    <bean:write name="lfiltro" property="filtro" /> 
                    </div>
                </display:column>
                <display:column headerClass="headerTable" title="Valor1" class="Numero" sortable="true">
                    <div align="center">
                    <bean:write name="lfiltro" property="valor" /> 
                    </div>
                </display:column>
                <display:column headerClass="headerTable" title="Valor2" class="Numero" sortable="true">
                    <div align="center">
                    <bean:write name="lfiltro" property="valor2" /> 
                    </div>
                </display:column>
                <display:column headerClass="headerTable" title="Eliminar" class="Numero" sortable="true">
                    <div align="center">
                        <%
                            java.util.HashMap params = new java.util.HashMap();
                            params.put("accion", "Delete");
                            pageContext.setAttribute("parametros", params);
                       %>
                        <html:link name="parametros" onclick="return confirm('Esta seguro que desea eliminar el filtro?')" paramId="codigos" paramName="lfiltro" paramProperty="codigo" page="/Reportes/GrupoFamiliar/TotalSelectFilterRGF.do">
                          <div align="center"><img src="<%= request.getContextPath() + "/images/Delete.gif" %>" width="16" height="16" border="0"></div>
                        </html:link>   
                    </div>
                </display:column>
           </display:table>     
        </td>
      </tr>
    </table>
  </logic:present>
</form>
</body>
</html>
